class Solution
{
public:
    int maxArea(vector<int>& height)
    {
        vector<int> sum;
        int end = height.size() - 1, begin = 0;

        while (begin < end)
        {
            sum.push_back((min(height[end], height[begin])) * (end - begin));
            if (height[begin] <= height[end]) begin++;
            else end--;
        }
        int ret = sum[0];
        for (auto e : sum) ret = max(e, ret);
        return ret;
    }
};